import Request from '../index'
import { ArticleResult, ArtilceData, ArticleLikeNum, ArticleLikeResult } from "./type"

// 文章列表
export function getArticleList() {
  return Request.get<ArticleResult>({
    url: 'api/article',
  })
}

// 发表文章
export function addArticle(data: ArtilceData) {
  return Request.post({
    url: 'api/article',
    headers: {
      'content-type': 'multipart/form-data'
    },
    data
  })
}

// 获取点赞数量
export function getLikeNum(data: ArticleLikeNum) {
  return Request.get<ArticleLikeResult>({
    url: 'api/getlike',
    params: {
      ...data
    }
  })
}

// 点赞
export function likeArticle(data: ArticleLikeNum) {
  return Request.post({
    url: 'like/addlike',
    headers: {
      'content-type': 'multipart/form-data'
    },
    data
  })
}
// 取消点赞
export function delLikeArticle(data: ArticleLikeNum) {
  return Request.post({
    url: 'like/dellike',
    headers: {
      'content-type': 'multipart/form-data'
    },
    data
  })
}